#include <stdio.h>
#include <string.h>
void bubble(char *b[100],int len)//冒泡排序
{
    for(int k=0;k<len-1;k++)
    {
        for(int j=0;j<len-k-1;j++)
        {
            if(strcmp(b[j],b[j+1])>0)
            {
               char *temp=b[j];
                b[j]=b[j+1];
                b[j+1]=temp;
                
            }
        }
    }

}

int main(){

    char a[100], *b[100];//a存储，b排序

    printf("Please input the words you want:\n");
    gets(a);
    
    char* n;
    n=strtok(a," ");//分割

    int i;
    i=0;
    while(n!=NULL)
    {
        b[i]=n;
        printf("%s\n",b[i]);
        i++;
        n= strtok(NULL," ");   
       
    }
    b[i]='\0';
    bubble(b,i);//冒泡排序
    
    for(int q=0;q<i;q++)
    {
       printf("%s ",b[q]);
    }


    
}